<style>
    table tbody tr:hover {
        background-color: #efefef;
    }
    .form-control{
        padding: 0px 1px;
        height: 26px;
    }
    .switch{
        width: 28px;
        height: 14px;
    }
    .switch small{
        width: 14px;
        height: 14px;
    }
    .switch.checked small{
        left: 13px;
    }
    .run_color{
        color: #00a157;
    }
    .stop_color{
        color: #ac2925;
    }
    .info_icon_warn{
        color: #E9DC51;
    }
    .info_icon_error{
        color: #ac2925;
    }
    .info_icon_info{
        color: #54596a;
    }
    .popover-content{
        padding: 0px;
    }
    .popover_div{
        overflow:auto;
    }
    .popover_table{
        margin-bottom: 0px;
        width: auto;
    }
    .popover_table_td{
        width: 125px!important;
    }
    .zone_tab{
        color:#000080;
        font-weight: bold;
    }
    .i_class{
        font-size: 18px;
        width: 19px;
    }
    .nav-tabs>li.active>a, .nav-tabs>li.active>a:focus, .nav-tabs>li.active>a:hover{
        background-color:#f4f4f4;
    }
</style>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box" id="content">
                <div class="box-header" id="header">
                    uCloud IP&nbsp;:&nbsp;{{info.vmInfo.ip}}&nbsp;&nbsp;&nbsp;&nbsp;状态&nbsp;:&nbsp;<span ng-class="{'running':'run_color','stop':'stop_color','error':'stop_color'}[info.vmStatus]">{{info.vmStatus}}</span>
                    <button class="btn btn-default" ng-if="arrayContains(info.userRole , 'admin')||arrayContains(info.userRole , 'ops')" style="margin-left: 10%;" uib-popover="查看api" popover-trigger="mouseenter" popover-placement="bottom" data-ng-click="openApi();">查看api</button>
                    <button class="btn btn-default" ng-if="arrayContains(info.userRole , 'admin')||arrayContains(info.userRole , 'ops')" style="margin-left: 5%;" uib-popover="勾选checkbox后可进行批量发布" popover-trigger="mouseenter" data-ng-click="batchRelease();" popover-placement="bottom" >批量发布</button>
                    <button class="btn btn-default" ng-if="arrayContains(info.userRole , 'admin')||arrayContains(info.userRole , 'ops')" style="margin-left: 5%;" uib-popover="勾选checkbox后可进行批量重启应用" popover-trigger="mouseenter" data-ng-click="batchRestart();" popover-placement="bottom" >批量重启</button>
                    <button class="btn btn-default" ng-if="arrayContains(info.userRole , 'admin')||arrayContains(info.userRole , 'ops')" style="margin-left: 5%;" uib-popover="勾选checkbox后可进行批量停止应用" popover-trigger="mouseenter" data-ng-click="batchStop();" popover-placement="bottom" >批量停止</button>
                    <button class="btn btn-default" ng-if="arrayContains(info.userRole , 'admin')||arrayContains(info.userRole , 'ops')" style="margin-left: 5%;" uib-popover="重新加载app" popover-trigger="mouseenter" popover-placement="bottom" data-ng-click="reloadApp();">加载app</button>
                    <br>
                    <input type="search" ng-model="search.app_name" style="width: 220px;" placeholder="Search Project Name Here..." />
                </div>
                <div class="box-body" style="margin-top:1px;">
                    <ul id="myTab" class="nav nav-tabs">
                        <li class="" data-ng-repeat="zone in info.zones track by $index" ng-class="{true:'active',false:''}[$index==info.tabIndex]">
                            <a style="cursor: pointer;" ng-click="tabClick($index,zone);" uib-popover="{{zone.zone_alias}}" popover-trigger="mouseenter" popover-placement="head" data-toggle="tab" ng-class="{true:'zone_tab',false:''}[zone.zone_title.indexOf('区') != -1]">
                                {{zone.zone_title}}</a>
                        </li>
                    </ul>
                    <div id="myTabContent" class="tab-content">
                        <div class="tab-pane fade" ng-class="{true:'in active',false:''}[true]">
                            <table class="table table-bordered">
                                <thead id="thead">
                                <tr style="display:block;">
                                    <th width="2%">
                                        <input type="checkbox" data-ng-click="checkAll();" data-ng-model="info.checkAll" ng-true-value="true" ng-false-value="false"/>
                                    </th>
                                    <th width="18%" colspan="2">应用名</th>
                                    <th width="35%" colspan="2">待发布版本</th>
                                    <th width="9%" colspan="3">状态</th>
                                    <th width="11%">应用操作</th>
                                    <th width="10%">提测/通过/待发版</th>
                                    <th width="10%">日志</th>
                                    <!--<th width="10%">操作</th>-->
                                </tr>
                                </thead>
                                <tbody id="tbody" style="display:block;overflow:auto;">
                                <tr class="item" data-ng-repeat="app in info.apps | filter:search ">
                                    <td width="2%">
                                        <input type="checkbox" data-ng-model="app.check" ng-true-value="true" ng-false-value="false"/>
                                    </td>
                                    <td width="15%">
                                        <a href="javascript:void(0)" ng-click="openApp(app);" ng-if="app.ucUrl != ''">{{app.app_name}}</a>
                                        <span ng-if="app.ucUrl == ''">{{app.app_name}}</span>
                                        <span ng-show="false">{{app.app_id}}</span>
                                    </td>
                                    <td width="3%">
                                        <i class="glyphicon glyphicon-warning-sign i_class" style="color: #ac2925;" popover-title="UCloud部署版本信息" popover-placement="left" popover-trigger="outsideClick" uib-popover-html="app.versionTip" ng-if="showVersionIcon(app) == 'false'" />
                                        <i class="glyphicon glyphicon-ok-sign i_class" style="color: #00a65a;" popover-title="UCloud部署版本信息" popover-placement="left" popover-trigger="outsideClick" uib-popover-html="app.versionTip" ng-if="showVersionIcon(app) == 'true'" />
                                        <i class="glyphicon glyphicon-warning-sign i_class" style="color: #E9DC51;" popover-title="UCloud部署版本信息" popover-placement="left" popover-trigger="outsideClick" uib-popover-html="app.versionTip" ng-if="showVersionIcon(app) == 'warn'" />
                                    </td>
                                    <td width="32%">
                                        <div ng-if="app.on_beetle == 'false'">
                                            <span ng-if="app.version != '-1'">{{app.version}}</span>
                                            <span ng-if="app.version == '-1'">/mnt/winitRelease/latest.product/{{app.app_name}}</span>
                                        </div>
                                        <div ng-if="app.on_beetle == 'true'">
                                            <div style="width: 48%;float: left;">
                                                <input type="text" ng-model="app.projectInfo" placeholder="Select Project" uib-typeahead="project as project.projectName for project in app.projectList | filter:{projectName:$viewValue}|limitTo:15" typeahead-template-url="selectTemplate.html" class="form-control" typeahead-show-hint="true" typeahead-min-length="0" typeahead-on-select="projectChange(app);" typeahead-select-on-blur="true" typeahead-append-to-body="true" />
                                                <!--<input type="text" ng-disabled="app.isRunning" ng-model="app.projectInfo" placeholder="Select Project" uib-typeahead="project as project.projectName for project in app.projectList | filter:{projectName:$viewValue}" typeahead-template-url="selectTemplate.html" class="form-control" typeahead-show-hint="true" typeahead-min-length="0" typeahead-on-select="projectChange(app);" typeahead-select-on-blur="true" typeahead-append-to-body="true" />-->
                                            </div>
                                            <div style="width: 48%;float: right;">
                                                <input type="text" ng-model="app.editionInfo" placeholder="Select Edition" uib-typeahead="edition as edition.showNum for edition in app.editionList | filter:{showNum:$viewValue}|limitTo:15" typeahead-template-url="selectTemplate.html" class="form-control" typeahead-show-hint="true" typeahead-min-length="0" typeahead-select-on-blur="true" typeahead-on-select="editionChange(app);" typeahead-append-to-body="true" />
                                                <!--<input type="text" ng-disabled="app.isRunning" ng-model="app.editionInfo" placeholder="Select Edition" uib-typeahead="edition as edition.showNum for edition in app.editionList | filter:{showNum:$viewValue}" typeahead-template-url="selectTemplate.html" class="form-control" typeahead-show-hint="true" typeahead-min-length="0" typeahead-select-on-blur="true" typeahead-on-select="editionChange(app);" typeahead-append-to-body="true" />-->
                                            </div>

                                        </div>
                                    </td>
                                    <td width="3%">
                                        <i class="glyphicon glyphicon-record" uib-popover="基础组件,固定版本" popover-trigger="mouseenter" ng-if="app.on_beetle == 'false'" />
                                        <i class="glyphicon glyphicon-record" style="color: #86d74f;" uib-popover="当前选择版本为线上版本" popover-trigger="mouseenter" ng-if="tr_color(app) == 'online'" />
                                        <i class="glyphicon glyphicon-thumbs-up" style="color: #f4ca06" uib-popover="当前选择版本为测试通过版本" popover-trigger="mouseenter" ng-if="tr_color(app) == 'qaTest'" />
                                    </td>
                                    <td width="3%">
                                        <i class="glyphicon glyphicon-minus-sign i_class" style="color: #ac2925;" data-toggle="popover" data-placement="auto top" data-content="{{app.statusTip}}" data-html="true" data-title="状态" data-trigger="hover" ng-if="showStatusIcon(app) == 'stop'" />
                                        <i class="glyphicon glyphicon-play i_class" style="color:#00a65a;" data-toggle="popover" data-placement="auto top" data-content="{{app.statusTip}}" data-html="true" data-trigger="hover" data-title="状态" ng-if="showStatusIcon(app) == 'running'" />
                                        <img style="width: 15px;height: 15px;vertical-align:baseline;" src="/beetle/image/loading.gif" ng-if="app.isRunning" data-toggle="popover" data-placement="auto top" data-content="{{app.statusTip}}" data-html="true" data-trigger="hover"/>
                                    </td>
                                    <td width="3%">
                                        <!--<i class="glyphicon glyphicon-info-sign i_class" popover-title="信息" popover-trigger="outsideClick" uib-popover-html="app.infoTip" ng-class="{'info':'info_icon_info','error':'info_icon_error','warn':'info_icon_warn'}[showInfoIcon(app)]" ng-show=""/>-->
                                        <i class="glyphicon glyphicon-info-sign i_class info_icon_info" popover-title="信息" popover-placement="left" popover-trigger="outsideClick" uib-popover-html="app.infoTip" ng-show="showInfoIcon(app) == 'info'"/>
                                        <i class="glyphicon glyphicon-info-sign i_class info_icon_warn" popover-title="信息" popover-placement="left" popover-trigger="outsideClick" uib-popover-html="app.infoTip" ng-show="showInfoIcon(app) == 'warn'"/>
                                        <i class="glyphicon glyphicon-info-sign i_class info_icon_error" popover-title="信息" popover-placement="left" popover-trigger="outsideClick" uib-popover-html="app.infoTip" ng-show="showInfoIcon(app) == 'error'"/>
                                    </td>
                                    <td width="3%">
                                        <i class="glyphicon glyphicon-pushpin" style="font-size:14px;width:18px;" popover-trigger="mouseenter" uib-popover="该工程进行过操作" ng-show="app.doRun"/>
                                    </td>
                                    <td width="11%">
                                        <i class="glyphicon glyphicon-check i_class" ng-show="btnShow('check',app,0)" data-ng-click="doCheck(app);" uib-popover="检查工程配置文件是否正确" popover-trigger="mouseenter"/>
                                        <i class="glyphicon glyphicon-check i_class" ng-show="!btnShow('check',app,0)" uib-popover="检查工程配置文件是否正确" popover-trigger="mouseenter" style="color: grey;"/>

                                        <i class="glyphicon glyphicon-briefcase i_class" ng-show="btnShow('build',app,0)" data-ng-click="doBuild(app);" uib-popover="构建" popover-trigger="mouseenter"/>
                                        <i class="glyphicon glyphicon-briefcase i_class" ng-show="!btnShow('build',app,0)" uib-popover="构建" popover-trigger="mouseenter" style="color: grey;"/>

                                        <i class="glyphicon glyphicon-cloud-download i_class" ng-show="btnShow('release',app,0)" data-ng-click="doRelease(app);" uib-popover="选择版本后可进行发布" popover-trigger="mouseenter"/>
                                        <i class="glyphicon glyphicon-cloud-download i_class" ng-show="!btnShow('release',app,0)" uib-popover="选择版本后可进行发布" popover-trigger="mouseenter" style="color: grey;"/>

                                        <!--<i class="glyphicon glyphicon-stop i_class" ng-show="btnShow('stop',app,0) && app.app_type != 'php'" data-ng-click="doStop(app);" uib-popover="停止服务器,发布过版本后才能进行该操作" popover-trigger="mouseenter"/>-->
                                        <i class="glyphicon glyphicon-stop i_class" ng-show="app.app_type != 'php'" data-ng-click="doStop(app);" uib-popover="停止服务器,发布过版本后才能进行该操作" popover-trigger="mouseenter"/>
                                        <!--<i class="glyphicon glyphicon-stop i_class" ng-show="!btnShow('stop',app,0) && app.app_type != 'php'" uib-popover="停止服务器,发布过版本后才能进行该操作" popover-trigger="mouseenter" style="color: grey;"/>-->

                                        <!--<i class="glyphicon glyphicon-repeat i_class" ng-show="btnShow('restart',app,0) && app.app_type != 'php'" data-ng-click="doRestart(app);" uib-popover="重启服务器,发布过版本后才能进行该操作" popover-trigger="mouseenter"/>-->
                                        <i class="glyphicon glyphicon-repeat i_class" ng-show="app.app_type != 'php'" data-ng-click="doRestart(app);" uib-popover="重启服务器,发布过版本后才能进行该操作" popover-trigger="mouseenter"/>
                                        <!--<i class="glyphicon glyphicon-repeat i_class" ng-show="!btnShow('restart',app,0) && app.app_type != 'php'" uib-popover="重启服务器,发布过版本后才能进行该操作" popover-trigger="mouseenter" style="color: grey;"/>-->

                                        <i class="glyphicon glyphicon-wrench i_class" ng-show="app.app_name == 'dep'" data-ng-click="fixApp(app);" uib-popover="修复服务" popover-trigger="mouseenter"/>


                                        <i class="glyphicon glyphicon-refresh i_class" ng-show="app.db_name != '' && app.db_type != ''" data-ng-click="reImportData(app);" uib-popover="重新导入数据库数据" popover-trigger="mouseenter"/>

                                    </td>
                                    <td width="10%">
                                        <i class="glyphicon glyphicon-hand-right i_class" ng-show="btnShow('toTest',app)" data-ng-click="toTest(true,app);" uib-popover="提交测试" popover-trigger="mouseenter"/>
                                        <i class="glyphicon glyphicon-hand-right i_class" ng-show="btnShow('dis_toTest',app)" uib-popover="提交测试" popover-trigger="mouseenter" style="color: grey;"/>

                                        <i class="glyphicon glyphicon-remove i_class" ng-show="btnShow('notToTest',app)" data-ng-click="toTest(false,app);" uib-popover="取消提交测试" popover-trigger="mouseenter"/>
                                        <i class="glyphicon glyphicon-remove i_class" ng-show="btnShow('dis_notToTest',app)" uib-popover="取消提交测试" popover-trigger="mouseenter" style="color: grey;"/>

                                        <i class="glyphicon glyphicon-thumbs-up i_class" ng-show="btnShow('testPass',app)" data-ng-click="testPass(true,app);" uib-popover="测试通过" popover-trigger="mouseenter"/>
                                        <i class="glyphicon glyphicon-thumbs-up i_class" ng-show="btnShow('dis_testPass',app)" uib-popover="测试通过" popover-trigger="mouseenter" style="color: grey;"/>

                                        <i class="glyphicon glyphicon-thumbs-down i_class" ng-show="btnShow('notTestPass',app)" data-ng-click="testPass(false,app);" uib-popover="测试不通过" popover-trigger="mouseenter"/>
                                        <i class="glyphicon glyphicon-thumbs-down i_class" ng-show="btnShow('dis_notTestPass',app)" uib-popover="测试不通过" popover-trigger="mouseenter" style="color: grey;"/>
                                    </td>
                                    <td width="10%">
                                        <button class="btn btn-default btn_class" data-ng-click="openShowLogModal('app','lg')" uib-popover="应用日志" popover-trigger="mouseenter">...</button>
                                        <button class="btn btn-default btn_class" data-ng-click="openShowLogModal('pip-app','lg')" uib-popover="应用发布日志" popover-trigger="mouseenter" style="margin-left: 5px;">...</button>
                                        <button class="btn btn-default btn_class" data-ng-click="openShowLogModal('pip-db','lg')" uib-popover="数据库发布日志" popover-trigger="mouseenter" style="margin-left: 5px;">...</button>
                                        <button class="btn btn-default btn_class" ng-if="app.editionInfo.editionNum == 'default'" data-ng-click="openShowLogModal('build','lg')" uib-popover="应用构建日志" popover-trigger="mouseenter" style="margin-left: 5px;">...</button>
                                    </td>
                                    <!--<td width="10%">-->
                                        <!--<button class="btn btn-default btn_class" data-ng-click="toRunSql('lg')" uib-popover="执行sql" popover-trigger="mouseenter">SQL</button>-->
                                    <!--</td>-->
                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<script type="text/ng-template" id="ucLogModal.html">
    <div class="modal-header">
        <h3 class="modal-title">日志<small><cite title="Source Title">{{logPath}}</cite></small></h3>
    </div>
    <div class="modal-body" id="log_div" style="height: 500px;overflow: auto;">
        <div ng-bind-html="log"></div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-primary" type="button" ng-click="getLog()">刷新日志</button>
        <button class="btn btn-primary" type="button" ng-click="cancel()">关闭</button>
    </div>
</script>
<script type="text/ng-template" id="sqlModal.html">
    <div class="modal-header">
        <h3 class="modal-title">执行SQL</h3>
    </div>
    <div class="modal-body">
        sql : <input type="text" ng-model="info.sql" style="width: 80%;" />
        <button style="margin-left: 20px;" class="btn btn-info" ng-click="runSql();" ng-if="!info.runIng">执行</button>
        <img style="width: 20px;height: 20px;margin-left: 20px;" src="/beetle/image/loading.gif" ng-if="info.runIng" uib-popover="执行中..." popover-trigger="mouseenter"/>
    </div>
    <div class="modal-footer">
        <button class="btn btn-primary" type="button" ng-disabled="info.runIng" ng-click="cancel()">关闭</button>
    </div>
</script>